interface callback<K,V>{
(key:K,value:V):void
}
class dictionary<K, V> {
     private keys: K[] = [];
     private values: V[] = [];
    get size(){
         return this.keys.length
    }
    set(key: K, value: V):boolean {
        let i = this.keys.indexOf(key);
        if (i < 0) {
            this.keys.push(key)
            this.values.push(value)

        } else {
            this.values[i] = value
        }
        return true
    }
    get(key:K):V{
        return this.values[this.keys.indexOf(key)]
    }
    delete(key:K):boolean {
        let i = this.keys.indexOf(key);
        if (i < 0) {
            return false
        }else{
            this.keys.splice(i, 1)
            this.values.splice(i,1)
            return true
        }
    }
    has(key:K){
        return this.keys.includes(key)
    }
    forEach(callback:callback<K,V>){
        for(let i = 0; i < this.keys.length; i++){
            callback(this.keys[i],this.values[i])
        }
    }

}
let map = new dictionary<string,number>()
map.set('1',1)
map.set('2',2)
map.set('3',2)
map.delete('3')
console.log(map.get('1'))
console.log(map.get('3'))
console.log(map.has('1'))
console.log(map.has('4'))
console.log(map.size)
map.forEach((key,value)=>{
    console.log(key,value)
})
console.log(map)